<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>购物车示例</title>
    <link rel="stylesheet" href="./css/style.css">

</head>

<body>
    <div id="app" v-cloak>        
        <template v-if="list.length">
            <!-- 商品列表信息 -->
            <table>
                <thead>
                    <tr>
                        <th><input type="checkbox" v-model:checked="inputChecked" @change = "handleChange"></th>
                        <th>序号</th>
                        <th>id</th>
                        <th>商品名称</th>
                        <th>商品单价</th>
                        <th>购买数量</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <!-- 用v-for指令循出数组list -->
                <tbody>
                    <tr v-for="(item,index) in list">
                        <td><input type="checkbox" v-model:checked="item.isChecked" @change=handleChangeOther></td>
                        <td>{{index +1}}</td>
                        <td>{{item.id}}</td>
                        <td>{{item.ProName}}</td>
                        <td>{{item.ProPrice}}</td>
                        <td>
                            <!-- button按钮用于增加减少数量 -->
                            <button   @click = "handleRedece(index)" :disabled = "item.count === 1">-</button>
                            {{item.count}}
                            <button @click="handleAdd(index)">+</button>
                        </td>
                        <td>
                            <button @click="handleRemove(index)">移除</button>
                        </td>
                    </tr>
                </tbody>
            </table>
            <!-- 带千位的分隔符号的商品总价 -->
            <div>总价:￥{{totalProice}}</div>
        </template>
        <!-- 提示购物车为空 -->
        <div v-else>购物车为空呀，快去逛逛商场吧</div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="./js/index.js"></script>
</body>
</html>